<!-- ************************************************************************************************************ -->
<!-- fileName          : SaveLeftguidePage.jsp 																	  -->
<!-- author            : 马文军 																					  --> 
<!-- createDate        : 2014/12/31 																			  -->
<!-- summary           : admin端  “左侧目录”  保存页面     后台逻辑 													  		  -->
<!-- modifiedBy        : 马文军																				      -->
<!-- ************************************************************************************************************ -->

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>SaveLeftguidePage</title>
<style type="text/css">

</style>

</head>
<body>
<%
	//设置请求的字符编码以支持中文
	request.setCharacterEncoding ("utf-8");

	//从请求页面获取表单参数
    String id = request.getParameter("id");
    System.out.println("更新leftguide页面	id="+id);
    String name = request.getParameter("title");
    String content_name = request.getParameter("content_name");
    String content = request.getParameter("content");
    
    java.util.Date sysDate = new java.util.Date();	//获取系统当前日期
	java.sql.Timestamp ts = new java.sql.Timestamp(sysDate.getTime()); //将系统日期转换为数据库时戳类型
	java.sql.Date date = new java.sql.Date(ts.getTime());	//从时戳中提取日期

    
	//从web.xml文件获取全局参数
	String drv=config.getServletContext().getInitParameter("DBDriver");
	String url=config.getServletContext().getInitParameter("DBURL");
	String uid=config.getServletContext().getInitParameter("DBUser");
	String pwd=config.getServletContext().getInitParameter("DBPass");
	
    //构建SQL字符串和JDBC对象
    
	String strSQL1 = "update immie0_immi.leftguide set name=?,content_name=?,content=?,date=? where id=? ";
	Connection conn = null;
	PreparedStatement pstmt = null;	
	
	try {
		Class.forName(drv).newInstance();
		conn = DriverManager.getConnection(url,uid,pwd);
		pstmt = conn.prepareStatement(strSQL1);
		pstmt.setString(1, name);
		pstmt.setString(2, content_name);
		pstmt.setString(3, content);
		//pstmt.setDate(3, date);
		pstmt.setTimestamp(4, ts);
		pstmt.setString(5, id);

		pstmt.executeUpdate();  
      
		response.sendRedirect("./EditLeftguidePage.do?id="+id);
	} catch (ClassNotFoundException e) {
		e.printStackTrace();
	} catch (InstantiationException e) {
	    e.printStackTrace();
	} catch (IllegalAccessException e) {
		e.printStackTrace();
	} catch (SQLException e) {
		e.printStackTrace();
	} 
	finally {
		if (pstmt != null) {
			pstmt.close();
			pstmt = null;
		}		
		if (conn != null) {
			conn.close();
			conn = null;
		}
	}
%>
</body>
</html>